package com.lsl.abstract_factory.listfactory;

import com.lsl.abstract_factory.factory.Page;

import java.util.Iterator;

/**
 * @author Zed
 * @description
 * @date 2022/11/27 22:09
 */
public class ListPage extends Page {


    public ListPage(String title, String authorName) {
        super(title, authorName);
    }

    @Override
    public String makeHTML() {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<html><head><title>" + title + "</title></head>\n");
        stringBuffer.append("<body>\n");
        stringBuffer.append("<h1>" + title + "</h1>\n");
        stringBuffer.append("<ul>\n");
        Iterator iterator = content.iterator();
        while (iterator.hasNext()) {
            com.lsl.abstract_factory.factory.Item item = (com.lsl.abstract_factory.factory.Item) iterator.next();
            stringBuffer.append(item.makeHTML());
        }
        stringBuffer.append("</ul>\n");
        stringBuffer.append("<hr><address>" + authorName + "</address>");
        stringBuffer.append("</body></html>\n");
        return stringBuffer.toString();
    }
}
